package com.lazy.service.impl;

import com.lazy.entity.User;
import com.lazy.dao.UserDao;
import com.lazy.service.UserService;
import com.lazy.utils.RespBean;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    @Override
    public RespBean login(User user, HttpServletRequest request) {
        User us = userDao.login(user);
        if (us!=null){
            request.getSession().setAttribute("token",true);
            return RespBean.success("登录成功",us);
        }
        return RespBean.error("登录失败");
    }
}
